Skip to content

refactor: multi_agent/ package shims (pre-split prep)#51

Draft
Simon-Free wants to merge 5 commits intoSafeRL-Lab:mainfrom
Simon-Free:pr5-multi-agent-split
Draft

refactor: multi_agent/ package shims (pre-split prep)#51
Simon-Free wants to merge 5 commits intoSafeRL-Lab:mainfrom
Simon-Free:pr5-multi-agent-split

Conversation

@Simon-Free
Copy link
Copy Markdown

@Simon-Free Simon-Free commented Apr 17, 2026

Summary

Introduce a multi_agent/ package with shim modules (definitions.py, manager.py, task.py, tools.py, subagent.py) that re-export the relevant names from the 480-line multi_agent/subagent.py monolith. Also add a root-level subagent.py proxy for back-compat with callers that import from subagent import ....

What this PR is - and is not

Is: a non-breaking preparation step. Callers can now import via the new paths (from multi_agent.manager import SubAgentManager, from multi_agent.task import SubAgentTask, etc.) without any change to runtime behaviour.

Is not: the actual split. multi_agent/subagent.py is still 480 lines; code was not moved out of it. The follow-up PR will physically move AgentDefinition / SubAgentManager / SubAgentTask implementations into their respective modules, at which point the re-export shims become real modules and the old file becomes a thin re-exporter or gets deleted. Splitting in two steps keeps the first PR trivial to review and lets new callers migrate to the new import paths before the move.

Changes

File +/- What
multi_agent/__init__.py +1 Expose the package
multi_agent/definitions.py +10 Re-export AgentDefinition, get_agent_definition, load_agent_definitions from subagent
multi_agent/manager.py +4 Re-export SubAgentManager
multi_agent/task.py +11 Re-export SubAgentTask + helpers
multi_agent/tools.py +1 Re-export the Agent tool registration point (preserved)
multi_agent/subagent.py +1 Proxy to the original file location during the transition
subagent.py (root) +1 Re-export so legacy from subagent import . keeps working
tests/test_multi_agent_split.py +55 Verify new import paths resolve to the same classes as the monolith, and that the root-level shim still works
tests/test_subagent.py +1 Import-compat assertion

Why no e2e test in this PR

There is no new behaviour to exercise - only module re-exports. Any real e2e (subagent spawn / task life-cycle / transcript capture) stays valid whichever import path the caller uses, so it belongs with the physical split in the follow-up PR. The test_multi_agent_split module asserts identity (AD is AgentDefinition), which is the strongest guarantee possible for a shim layer.

Ref #43

@Simon-Free Simon-Free marked this pull request as draft April 17, 2026 19:45
@Simon-Free Simon-Free changed the title refactor: split subagent.py into multi_agent/ package refactor: multi_agent/ package shims (pre-split prep) Apr 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant